package com.zwps.biz.controller.common;

import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;

import com.zwps.biz.domain.tool.JwtTool;
import com.zwps.common.controller.CommonController;
import com.zwps.common.controller.constant.HttpHeaderConstant;
import com.zwps.common.core.exception.AuthenticationFailureException;

import cn.hutool.core.util.StrUtil;

public class CommonSystemController extends CommonController {

    @Autowired
    private HttpServletRequest request;

    private String getToken() {
        String token = request.getHeader(HttpHeaderConstant.HEADER_TOKEAN);
        if (StrUtil.isEmpty(token)) {
            throw new AuthenticationFailureException("Token 缺失");
        }
        return token;
    }

    public String getRawToken() {
        String token = getToken();
        return JwtTool.getRawToken(token);
    }

}
